package com.huike.business.service.impl;


import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.clues.mapper.SysDictDataMapper;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 * 
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;

    @Autowired
    private SysDictDataMapper sysDictDataMapper;
    /**
     * 查询商机跟进数据
     * @param businessId
     * @return
     */
    @Override
    public List<TbBusinessTrackRecord> selectBusinessId(Long businessId) {
        List<TbBusinessTrackRecord> tbBusinessTrackRecords = tbBusinessTrackRecordMapper.selectBusinessId(businessId);
        List<String> list = new ArrayList<>();
        for (TbBusinessTrackRecord tbBusinessTrackRecord : tbBusinessTrackRecords) {
            String keyItems = tbBusinessTrackRecord.getKeyItems();
            String[] split = keyItems.split(",");
            for (String s : split) {
                String communication_point = sysDictDataMapper.selectDictValue("communication_point", s);
                list.add(communication_point);
                tbBusinessTrackRecord.setKeys(list);
            }
        }
        return tbBusinessTrackRecords;
    }
}
